import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "../views/HomeView.vue";

Vue.use(VueRouter);

const routes = [
  // 路由重定向/如果没有找到匹配的路由就重定向到首页
  {
    path: "/home",
    name: "home",
    component: HomeView,
  },
  // 一级路由 首页
  {
    path: "/",
    redirect:'/HomE'
  },
  // 一级路由 列表页面
  {
    path: "/LisT",
    name: "LisT",
    component: () => import("../views/LisT.vue"),
  },
  // 一级路由 购物车页面
  {
    path: "/CarT",
    name: "CarT",
    component: () => import("../views/CarT.vue"),
  },
  // 一级路由 我的页面
  {
    path: "/MyS",
    name: "MyS",
    component: () => import("../views/MyS.vue"),
  },
  // 一级路由 搜索页面
  {
    path: "/SearcH",
    name: "SearcH",
    children:[
      // 二级路由 搜索首页
      {
        path:'/',
        name:'index',
        component:() => import("../views/search/Search-Index.vue")
      },
      // 二级列表 搜索列表
      {
        path:'list',
        name:'list',
        component:() => import("../views/search/Search-List.vue")
      }
    ],
    component: () => import("../views/SearcH.vue"),
  },
  {
    path:'/detail',
    name:'detail',
    meta:{
      keepAlive:true,//此组件不缓存
    },
    component:()=> import('../views/DetaiL.vue')
  },
  {
    path:'/login',
    name:'login',
    component:()=> import('../views/login/LogiN.vue')
  },
  {
    path:'/UserLogin',
    name:'UserLogin',
    component:()=> import('../views/login/UserLogin.vue')
  },
  {
    path:'/register',
    name:'Register',
    component:()=> import('../views/login/RegisteR.vue')
  },
  {
    path: "/recovery",
    name: "recovery",
    children:[
      // 二级路由 搜索首页
      {
        path:'/',
        name:'index',
        component:() => import("../views/recovery/RecoveryIndex.vue")
      },
      // 二级列表 搜索列表
      {
        path:'btn',
        name:'btn',
        component:() => import("../views/recovery/RecoveryBtn.vue")
      }
    ],
    component: () => import("../views/recovery/RecoverY.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
